<?
@define("ADMIN",true);
@define("IN_PHPBB",true);


include_once('../common.php');
include_once($root_path . '/includes/category.php');
include_once($root_path . '/includes/item.php');

$tag=request_var('tag','');
$id=request_var('id',0);
$item = new Item($tag,$id);
$cat=new Category($item->data['catid']);
$action = request_var('action','');

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Simpla Admin</title>
<link rel="stylesheet" href="resources/css/reset.css" type="text/css" media="screen" />
<link rel="stylesheet" href="resources/css/style.css" type="text/css" media="screen" />
<link rel="stylesheet" href="resources/css/invalid.css" type="text/css" media="screen" />	
<script type="text/javascript" src="resources/scripts/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="resources/scripts/simpla.jquery.configuration.js"></script>
<script type="text/javascript" src="resources/scripts/facebox.js"></script>
<script type="text/javascript" src="resources/scripts/jquery.wysiwyg.js"></script>
</script>
</head>
<body>
<script type="text/javascript">
$(document).ready(function(){
$('.deleteImg').click(function(){
	var el=$(this)
	$.get('delete.php',{img: $(this).attr('rel')},function(data)
		{
			if(data=='true')
				el.hide();
			else
				alert("Error while try to delete this image!");
		});
});
});
</script>
<div class="content-box"><!-- Start Content Box -->
				<div class="content-box-header">
					
					<h3>
					<?php 
						echo $item->data['name'];
					?>
					</h3>			
					<div class="clear"></div>
					
				</div> <!-- End .content-box-header -->
				
				<div class="content-box-content">
						<?php
							echo '<div style="float:left;padding: 30px"><img height="150px" alt="" src="'.$root_path. $item->data['img'].'"/></div><div class="clear"></div>';
							foreach($item->images as $image)
							{
								echo '<a href="javascript:;" rel="'.$item->data['tag'].'-'.$item->data['id'].';'.$image.'" class="deleteImg"><div style="float:left;padding: 30px"><img height="150px" src="'.$root_path.$image.'" /><p align="center">Delete</p></div></a>';
							}
						?>
						<div class="clear"></div>
                        <form enctype="multipart/form-data" action="index.php?p=items&action=add&catid=<?php echo $catid; ?>" method="post">
                            <fieldset>
                                <p class="column-left">
                                    <label>Item's Name:</label>
                                    <input type="text" class="text-input medium-input" name="name" value="<?php echo $item->data['name']; ?>"/>
                                </p>
                                <p class="column-left">
                                    <label>Price:</label>
                                    <input type="text" class="text-input medium-input" name="price" value="<?php echo $item->data['price']; ?>"/>
                                </p>
                                <p class="column-left">
                                    <label>Sale off:</label>
                                    <input type="text" class="text-input medium-input" name="saleoff" value="<?php echo $item->data['saleoff']; ?>"/>
                                </p>
                                <!--p class="column-left">
                                    <label>Tag:</label>
                                    <input type="text" class="text-input medium-input" name="tag" value="<?php echo $item->data['tag']; ?>"/>
                                </p-->
								<div class="clear"></div>
                                <!--p class="column-left">
                                    <label>Amount:</label>
                                    <input type="text" class="text-input medium-input" name="amount" value="1"/>
                                </p-->
                                <div class="clear"></div>
								<p>
                                    <label>Description:</label>
                                    <textarea name="description" class="text-input textarea wysiwyg"><?php echo $item->data['description'];?></textarea>
                                </p>
                                <div class="clear"></div>
                                <p>
                                    <label>Primary Image:</label>
                                    <input type="file" name="image" />
                                </p>
                                <p id="moreimg">
                                    <label>More Images:</label>
                                    <input type="file" name="images[]" />&nbsp;&nbsp;&nbsp;<input class="button" type="button" onclick="add_upload()" value="Add Image"/>
                                </p>
                            </fieldset>
                            <input type="submit" value="Submit" class="button"/>&nbsp;&nbsp;&nbsp;<input type="reset" name="Reset"  class="button"/>
                        </form>
				</div> <!-- End .content-box-content -->
				
			</div> <!-- End .content-box -->	
</body>
</html>